package com.example.easy.Controller;


import com.example.easy.Dto.HealthSecurity;
import com.example.easy.Dto.PublicSecurity;
import com.example.easy.Dto.ResourceProtection;
import com.example.easy.Service.myservice.PublicSecurityServise;
import com.example.easy.Tools.ResultCode;
import com.example.easy.mapper.PublicSecurityMapper;
import com.example.easy.mapper.ResourceProtectionMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Scope("prototype")
@RestController
@Api(value = "ResourceProtection", description = "资源保护")
@RequestMapping(value = "/resourceProtection")

public class ResourceProtectionController {

    @Autowired
    ResourceProtectionMapper resourceProtectionMapper;

    @ApiOperation(value = "增加资源保护信息", notes = "增加资源保护信息")
    @RequestMapping(value = "/insResourceProtection", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object insResourceProtection(@RequestBody ResourceProtection  resourceProtection) throws IOException {

        return ResultCode.SUCCESS.result(resourceProtectionMapper.insResourceProtection(resourceProtection));

    }

    @ApiOperation(value = "修改资源保护信息", notes = "修改资源保护信息")
    @RequestMapping(value = "/updateResourceProtection", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateResourceProtection(@RequestBody ResourceProtection  resourceProtection) throws IOException {

        return ResultCode.SUCCESS.result(resourceProtectionMapper.updateResourceProtection(resourceProtection));

    }

    @ApiOperation(value = "删除资源保护信息", notes = "删除资源保护信息")
    @RequestMapping(value = "/deleteResourceProtection", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object deleteResourceProtection(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(resourceProtectionMapper.deleteResourceProtection(number));

    }

    @ApiOperation(value = "查看资源保护信息", notes = "查看资源保护信息")
    @RequestMapping(value = "/selectResourceProtection", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectResourceProtection(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(resourceProtectionMapper.selectResourceProtection(number));

    }

    @ApiOperation(value = "查看所有资源保护信息", notes = "查看所有资源保护信息")
    @RequestMapping(value = "/selectall", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectall() throws IOException {

        return ResultCode.SUCCESS.result(resourceProtectionMapper.selectall());

    }

}
